
/*
 * Hlpay-Plus aggregate payment system.
 * Copyright (c) 2024-2025 Hlpay Team Copyright has the right of final interpretation.
 */

package com.hlkj.pay.app.merchant.ext;

import javax.servlet.http.HttpServletRequest;

import com.hlkj.framework.common.pojo.CommonResult;
import com.hlkj.framework.extension.ExtensionPointI;
import com.hlkj.pay.app.merchant.ext.dto.order.ChannelPayOrderContext;
import com.hlkj.pay.app.merchant.ext.dto.order.ChannelPayOrderQueryContext;
import com.hlkj.pay.app.merchant.ext.dto.order.ChannelRefundPayOrderContext;
import com.hlkj.pay.dto.order.PayOrderChannelResultDto;
import com.hlkj.pay.dto.order.notify.CsOrderNotifyDto;
import com.hlkj.pay.dto.order.notify.RefundOrderNotifyDto;
import com.hlkj.pay.infrastructure.model.order.PayOrderDO;
import com.hlkj.pay.infrastructure.model.pay.PayWayDO;
import com.hlkj.pay.infrastructure.model.pay.ProviderChannelConfigDO;

/**
 * 商户交易
 * 
 * @author HlpayTeam
 * @date 2024/09/12 11:39
 */
public interface ChannelMerchantOrderExtPt extends ExtensionPointI {

    /**
     * 获取渠道订单号
     *
     * @param channelPayOrderContext
     */
    CommonResult<String> channelOrderCode(ChannelPayOrderContext channelPayOrderContext);

    /**
     * 提交渠道订单
     * 
     * @param channelPayOrderContext
     */
    void submitChannelPayOrder(ChannelPayOrderContext channelPayOrderContext);

    /**
     * 渠道订单查询
     * 
     * @param channelPayOrderQueryContext
     */
    void queryChannelPayOrder(ChannelPayOrderQueryContext channelPayOrderQueryContext);

    /**
     * 渠道订单关闭
     *
     * @param channelPayOrderQueryContext
     */
    void closeChannelPayOrder(ChannelPayOrderQueryContext channelPayOrderQueryContext);

    /**
     * 渠道关闭订单查询
     *
     * @param channelPayOrderQueryContext
     */
    void queryChannelClosePayOrder(ChannelPayOrderQueryContext channelPayOrderQueryContext);
    /**
     * 是否支付退款
     *
     * @param channelRefundPayOrderContext
     */
    boolean refundApply(ChannelRefundPayOrderContext channelRefundPayOrderContext);

    /**
     * 渠道订单退款
     *
     * @param channelRefundPayOrderContext
     */
    void refundChannelPayOrder(ChannelRefundPayOrderContext channelRefundPayOrderContext);

    /**
     * 渠道退款订单查询
     *
     * @param channelRefundPayOrderContext
     */
    void queryRefundChannelPayOrder(ChannelRefundPayOrderContext channelRefundPayOrderContext);

    /**
     * 支付回调
     *
     * @param request
     * @return
     */
    CommonResult<PayOrderChannelResultDto> orderStatusParse(HttpServletRequest request, ProviderChannelConfigDO providerChannelConfigDO);
    /**
     * 支付回调
     *
     * @param request
     * @return
     */
    CommonResult<PayOrderChannelResultDto> orderStatusParse(HttpServletRequest request);


    CommonResult<PayOrderChannelResultDto> merAuthParse(HttpServletRequest request);

    /**
     * 关闭订单回调
     *
     * @param request
     * @return
     */
    PayOrderDO closeOrderStatusParse(HttpServletRequest request, ProviderChannelConfigDO providerChannelConfigDO);

    CommonResult<CsOrderNotifyDto> csOrderStatusParse(HttpServletRequest request, ProviderChannelConfigDO providerChannelConfigDO);

    /**
     * 退款回调
     * 
     * @param request
     * @return
     */

    CommonResult<RefundOrderNotifyDto> refundStatusParse(HttpServletRequest request, ProviderChannelConfigDO providerChannelConfigDO);

    String channelPayCode(PayWayDO payWayDO);

    /**
     *
     * @param channelPayOrderContext
     * @return
     */
    Long queryChannelPayAppid(ChannelPayOrderContext channelPayOrderContext);
    /**
     * 返回信息
     *
     * @param commonResult
     * @return
     */
    String callBackResponse(CommonResult commonResult);

    /**
     * 提交渠道订单
     *
     * @param channelPayOrderContext
     */
    boolean wechatLink(ChannelPayOrderContext channelPayOrderContext);
}
